package com.study.storm.analytics;

import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.topology.TopologyBuilder;
import org.apache.storm.tuple.Fields;

/**
 * @author Mayjean
 * @Date2020/8/27 21:20
 */
public class TopologyStarter {

    public static void main(String[] args) {
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("read-feed", new UserSpout(),1);
        builder.setBolt("get-categ", new GetCategoryBolt(),1).shuffleGrouping("read-feed");
        builder.setBolt("user-history", new UserHistoryBolt(),1).fieldsGrouping("get-categ", new Fields("user"));


        Config conf = new Config();
        conf.setDebug(true);
        conf.put("redis-host","REDIS_HOST");
        conf.put("redis-port","REDIS_PORT");
        conf.put("webserver", "WEBSERVER");

        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("analytics", conf, builder.createTopology());
    }
}
